'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    // 用 'role_id', 'permission_id' 两列添加一个名为 "unique_index" 的唯一索引
    await queryInterface.addIndex(
      'role_permissions',
      ['role_id', 'permission_id'],
      {
        name: 'unique_index',
        unique: true,
      },
    );
  },

  async down(queryInterface, Sequelize) {
    // 删除名为 "unique_index" 的索引
    await queryInterface.removeIndex('role_permissions', 'unique_index');
  },
};
